//
//  DropDownViewController.m
//  基本框架
//
//  Created by runone02 on 2018/8/22.
//  Copyright © 2018年 liqiyun. All rights reserved.
//

#import "DropDownViewController.h"
#import "DropDownMenu.h"
@interface DropDownViewController ()
/** 图片*/
@property (nonatomic, strong) NSArray *images;
/** 标题*/
@property (nonatomic, strong) NSArray *titles;
/** 下拉框*/
@property (nonatomic, strong) DropDownMenu *dropDownMenu;
@end

@implementation DropDownViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self prepareData];
    [self setupNavView];
}

#pragma mark - private
- (void)prepareData {
    _images = @[@"1",@"2",@"3",@"4"];
    _titles = @[@"图片",@"音乐",@"视频",@"下载"];
    _dropDownMenu = [[DropDownMenu alloc] initWithWidth:150.0f images:_images titles:_titles];
}

- (void)setupNavView {
    WeakSelf(weakSelf);
    [self.navView.rightButton setTitle:@"点击" forState:UIControlStateNormal];
    self.navView.rightButtonBlock = ^{
        [weakSelf clickRightItem];
    };
}

- (void)clickRightItem{
    WeakSelf(weakSelf);
    [_dropDownMenu selectedAtIndex:^(NSInteger index) {
        NSLog(@"title:%@", weakSelf.titles[index]);
    }];
    [_dropDownMenu showMenu];
}

@end
